package com.app.worldcupapp.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.app.worldcupapp.R;
import com.app.worldcupapp.bean.TeamsBean;
import com.app.worldcupapp.bean.TeamsOrderBean;
import com.squareup.picasso.Picasso;

import java.util.List;

public class MyTeamsOrderListAdapter extends BaseAdapter {
    List list;
    Context context;

    public MyTeamsOrderListAdapter(List list, Context context) {
        this.list = list;
        this.context = context;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      View view = LayoutInflater.from(context).inflate(R.layout.activity_team_board_listview,parent,false);

        //这里写listview里面item的控件，findViewById前面要加上(view.)。
        TextView rankId = view.findViewById(R.id.rankId);
        TextView stateId = view.findViewById(R.id.stateId);
        TextView integral = view.findViewById(R.id.integral);
        ImageView orderTeamId = view.findViewById(R.id.orderTeamId);
        TeamsOrderBean.ListDTO teamsOrderBean = (TeamsOrderBean.ListDTO) list.get(position);
        rankId.setText(teamsOrderBean.getOrder());
        stateId.setText(teamsOrderBean.getNation());
        integral.setText(String.valueOf(teamsOrderBean.getScore())+"分");
      Picasso.with(context).load("http://192.168.27.206:8080/statics/"+teamsOrderBean.getFlag()).into(orderTeamId);

        return view;
    }
}
